﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="SooritaKanneVastus_v4", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(SooritaKanneVastusV4))]
    public class SooritaKanneVastusV4Serializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected ISooritaKanneVastusV4 clazz;
        
        public SooritaKanneVastusV4Serializer(ISooritaKanneVastusV4 clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("teade");
            if (clazz.Teade!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Teade))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Teade");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("legacy_lahendi_number");
            if (clazz.LegacyLahendiNumber!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.LegacyLahendiNumber))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("paevikukande_id");
            if (clazz.PaevikukandeId!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.PaevikukandeId))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("ettevotja_id");
            if (clazz.EttevotjaId!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.EttevotjaId))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
        START:
            if ((Reader.LocalName == "teade")) {
                goto teade;
            }
            else {
                if ((Reader.LocalName == "legacy_lahendi_number")) {
                    goto legacy_lahendi_number;
                }
                else {
                    if ((Reader.LocalName == "paevikukande_id")) {
                        goto paevikukande_id;
                    }
                    else {
                        if ((Reader.LocalName == "ettevotja_id")) {
                            goto ettevotja_id;
                        }
                        else {
                            return;
                        }
                    }
                }
            }
        teade:
            if (Reader.IsElementNil()) {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>SooritaKanneVastus_v4>teade");
            }
            clazz.Teade = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("teade")).Value;
            goto START;
        legacy_lahendi_number:
            if ((Reader.IsElementNil() == false)) {
                clazz.LegacyLahendiNumber = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("legacy_lahendi_number")).Value;
            }
            else {
                Reader.Skip();
            }
            goto START;
        paevikukande_id:
            if ((Reader.IsElementNil() == false)) {
                clazz.PaevikukandeId = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("paevikukande_id")).Value;
            }
            else {
                Reader.Skip();
            }
            goto START;
        ettevotja_id:
            if ((Reader.IsElementNil() == false)) {
                clazz.EttevotjaId = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("ettevotja_id")).Value;
            }
            else {
                Reader.Skip();
            }
            goto START;
        }
    }
}
